<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{margin: 0;padding:0;box-sizing: border-box}
        #box{
            height: 300px;
            background: #aef;
        }
    </style>
</head>
<body>
    <div id="box"></div>
    <script>
        //获取box
        let box = document.querySelector("#box");
        //绑定事件
        box.ontouchstart = function(){
            console.log('#box 被触摸了');
            this.start = Date.now();
        }

        //绑定单击事件
        box.onclick = function(){
            console.log('#box 被点击了');
            this.end = Date.now();
            console.log(this.end - this.start);
        }

        //触摸滑动事件
        box.ontouchmove = function(){
            console.log('#box 触摸滑动了');
        }

        //触摸结束事件
        box.ontouchend = function(){
            console.log('#box 手指离开!!!');
        }

        //触摸打断事件
        box.ontouchcancel = function(){
            console.log('触摸被打断了!!!');
        }

        setTimeout(() => {
            // alert('主人, 那家伙又来电话啦!!');
        }, 3000);

    </script>
</body>
</html>